<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var div = document.createElement('div');
        var body = document.body;
        var htmls = document.documentElement;
        // console.log(htmls);
        body.innerHTML = '<div><button>点击</button></div>';
        var div = document.querySelector('div');
        // div.innerHTML = '<button></button>';
        var btn = document.querySelector('button');
        div.style.width = 200 + 'px';
        div.style.height = 40 + 'px';
        div.style.backgroundColor = 'blue';
        btn.style.marginTop = 100 + 'px';
        btn.style.width = 50 + 'px';
        btn.style.height = 30 + 'px';
        //  var num = 1;
        btn.onclick = function() {
            if (div.style.width == 200+'px') {
                div.style.height = 200 + 'px';
                div.style.width = 40 + 'px';
                // var num = 0;
            } else {
                div.style.width = 200 + 'px';
                div.style.height = 40 + 'px';
                // var num = 1;
            }

        }
    </script>
</body>
</html>